<?php

require "include/bittorrent.php";
dbconn();
loggedinorreturn();
$HTMLOUT = "";
if ($CURUSER['class'] < UC_MODERATOR && $CURUSER['id'] != $betsadmin)
	stderr("错误", "权限不足");
$HTMLOUT .="<a href='bet.php'><img src='betting.png' alt='Bet' title='博彩' width='400' height='125' /></a>
<h1>竞猜管理</h1>
<table align='center' class='main' width='200' cellspacing='0' cellpadding='5' border='0'>
<tr>
<td align='center' class='navigations'><a href='bet_admin.php'><font color='red'>添加竞猜</font></a></td>
<td align='center' class='navigations'><a href='bet_gamefinish.php'>结束竞猜</a></td>
</tr></table><br />";
$HTMLOUT .="<form method='post' action='bet_takenew.php'>
<table align='center' cellpadding='5'>
<tr><td>标题：</td><td><input type='text' name='heading' size='50' /></td></tr>
<tr><td>条件 :</td><td><input type='text' name='undertext' size='50' value='获胜条件' /></td></tr>
<tr>
<td align='center'colspan='2'>结束时间
<input type='text' name='endtime' onfocus='WdatePicker({dateFmt: \"yyyy-MM-dd HH:mm:ss\", isShowWeek: \"true\", minDate: \"%y-%M-%d %H:%m:%s\"})' class='Wdate' style='width:160px'/>
</td>
</tr>
<tr>
<td>排序条件：</td><td>
<input type='radio' name='sort' value='1' checked='checked' />
押注时间<input type='radio' name='sort' value='0' />
押注金额</td></tr>
<tr><td colspan='2' align='center'>
<input  type='submit' value='添加' />
</td></tr></table></form>";
$HTMLOUT .="<br /><br />
<table align='center' cellpadding='5'>
<tr>
<td><b>庄家</b></td>
<td><b>结束时间</b></td>
<td><b>标题</b></td>
<td><b>条件</b></td>
<td><b>状态选项</b></td>
<td><b>添加选项</b></td>
<td><b>编辑选项</b></td>
</tr>";
$a = sql_query("SELECT *, endtime as end FROM betgames order by endtime ASC") or sqlerr(__FILE__, __LINE__);
while ($b = mysql_fetch_array($a)) {
	$HTMLOUT .="<tr><td align='left'>" . get_username($b['6']) . "</td>";
	if (time() > $b["end"])
		$HTMLOUT .="<td align='center'><i>" . htmlspecialchars(date('Y-m-d H:i:s', $b['3'])) . "</i></td>";
	else
		$HTMLOUT .="<td align='center'>" . htmlspecialchars(date('Y-m-d H:i:s', $b['3'])) . "</td>";
	$HTMLOUT .="<td align='center'>" . htmlspecialchars($b['1']) . "</td>";
	$HTMLOUT .="<td align='center'><i>" . htmlspecialchars($b['undertext']) . "</i></td>";
	if (time() > $b["end"])
		$HTMLOUT.="<td align='center'>待结束</td>";
	else
		$HTMLOUT .="<td align='center'><a href='bet_active.php?id=" . $b['0'] . "'><u>" . htmlspecialchars($b['active'] ? '进行中' : '未激活') . "</u></a></td>";
	$HTMLOUT .="<td align='center'><a href='bet_opt.php?id=" . $b['0'] . "'>添加</a></td>";
	$HTMLOUT .="<td align='center'><a href='bet_opt2.php?id=" . $b['0'] . "'>编辑</a></td></tr>";
}
$HTMLOUT .="</table><br /><br />\n";
stdhead('博彩');
print $HTMLOUT;
stdfoot();
